/**
 * create by young (young2f@outlook.com) on 2020/12/5
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('aiotBusiness');
  const json = {
    describe: { type: 'string' },
    treeId: { type: 'string' },
    table: { type: 'string' },
    level: { type: 'number' },
    name: { type: 'string' },
    title: { type: 'object' },
    path: { type: 'string' },
    desc: { type: 'object' },
    fatherId: { type: 'string' },
    fatherTitle: { type: 'string' },
    fatherName: { type: 'string' },
    editable: { type: 'boolean' },
    configs: { type: 'object' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Tree', _schema);
};
